package cn.syc.struck.demo;

/**
 * Created by Administrator on 2017/3/22.
 */


import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;

import com.tencent.bugly.crashreport.CrashReport;


public class App extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        //Logger.initialize(new Settings().isShowMethodLink(true)
        //        .isShowThreadInfo(false).setMethodOffset(0)
        //        .setLogPriority(BuildConfig.DEBUG ? Log.VERBOSE : Log.ASSERT));
        //-------------
        CrashReport.initCrashReport(getApplicationContext(), "b685f796d4", false);
    }

    private static App instance;

    public static App getInstance() {
        return instance;
    }

    final String sharedPreferencesName = "SettingInfo";

    public void setPrefValue(String key, String value) {
        SharedPreferences mSpSettingInfo = getSharedPreferences(sharedPreferencesName, Context.MODE_PRIVATE);
        SharedPreferences.Editor mEditor = mSpSettingInfo.edit();
        mEditor.putString(key, value).commit();
    }


    public String getPrefValue(String key, String defaultValue) {
        SharedPreferences mSpSettingInfo = getSharedPreferences(sharedPreferencesName, Context.MODE_PRIVATE);
        return mSpSettingInfo.getString(key, defaultValue);
    }

    public SharedPreferences getSharedPref() {
        return getSharedPreferences(sharedPreferencesName, Context.MODE_PRIVATE);
    }

    public String getUserAgent() {
        StringBuilder ua = new StringBuilder("App.Demo");
        ua.append("/Android");// 手机系统平台
        ua.append("/" + android.os.Build.VERSION.RELEASE);// 手机系统版本
        ua.append("/" + android.os.Build.MODEL); // 手机型号
        return ua.toString();
    }
}

